﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Principal;
using FeCMS.Common.Enum;

namespace FeCMS.AccessControlModule.Security
{
    /// <summary>
    ///     用户信息
    ///     用来标识当前访问者的信息
    /// </summary>
    public class UserInfo : IPrincipal
    {
        #region 属性

        /// <summary>
        ///     用户ID
        /// </summary>
        public long UserId;
        /// <summary>
        ///     角色ID
        /// </summary>
        public int RoleId;
        /// <summary>
        ///     用户名
        /// </summary>
        public string UserName;
        /// <summary>
        ///     访问者的类型
        /// </summary>
        public VisitorsType VisitorsType;

        #endregion


        public UserInfo(){}

        /// <summary>
        ///     实例化
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="roleId">角色ID</param>
        /// <param name="userName">用户名</param>
        /// <param name="visitorsType">访问者的类型</param>
        public UserInfo(long userId, int roleId, string userName,VisitorsType visitorsType)
        {
            UserId = userId;
            RoleId = roleId;
            UserName = userName;
            this.VisitorsType = visitorsType;
        }

        /// <summary>
        ///     返回字符串
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return string.Format("{0}€{1}€{2}€{3}",
                UserId, RoleId, UserName, (int)this.VisitorsType);
        }



        public IIdentity Identity
        {
            get { throw new NotImplementedException(); }
        }


        /// <summary>
        ///     判断是否在角色内
        /// </summary>
        /// <param name="role"></param>
        /// <returns></returns>
        public bool IsInRole(string role)
        {
            throw new NotImplementedException();
        }
    }
}
